<template>
    <div class="content">
        登录信息：{{userInfo}}
        <div id="myChart" :style="{width: '0px', height: '0px'}"></div>
    </div>
</template>

<script>
    let echarts = require('echarts')
    export default {
        name: "Index",
        props:["userInfo"],
        data(){
            return{
                myChart:null
            }
        },
        mounted() {
            if (!this.myChart) {
                this.myChart = echarts.init(document.getElementById('myChart'));
                console.log(this.myChart)
            }
        },
        created() {
            this.getMenus()
        },
        activated() {
            this.getMenus()
        },
        //离开路由之前执行
        beforeRouteLeave(to,from,next){
            //将下一个页面缓存
            // to.meta.keepAlive = true
            //将当前页面缓存
            // from.meta.keepAlive = true
            next()
        },
        methods: {
            //获取菜单列表
            getMenus(){
                let url = "menu/tree";
                this.$http.get(url).then(res => {
                    this.menuTree = res.data.data.items
                })
            }
        }
    }
</script>

<style scoped>

</style>
